Skip to content

feat: cross-plugin services (ctx.services) and three-class storage scopes#107

Merged
antfu merged 1 commit into
mainfrom
feat/core-services-storage
Jul 17, 2026
Merged

feat: cross-plugin services (ctx.services) and three-class storage scopes#107
antfu merged 1 commit into
mainfrom
feat/core-services-storage

Conversation

@antfubot

Copy link
Copy Markdown
Collaborator

Intent

Two context-level primitives that let independently-installed plugins cooperate, split out of the data-inspector work (#101, which stacks on this PR):

ctx.services — cross-plugin service registry

A typed, namespaced registry on the shared node context: one integration provide()s a capability, others consume it with get() / whenAvailable() — no package dependency between them. Providers augment the DevframeServicesRegistry interface, so consumers get full typing from a types-only import; whenAvailable fires immediately or on later provide, making provider/consumer mount order irrelevant. Duplicate ids throw the new DF0037 diagnostic. First consumer: the data-inspector's source registry (#101).

Storage scopes: workspace / project / global

getStorageDir gains a committable class and renames the old one:

  • workspace — committable, team-shared; conventionally <workspaceRoot>/.devframe/ (new semantics)
  • project — per-checkout private, under node_modules (the previous 'workspace' behavior)
  • global — per-user (unchanged)

All in-repo hosts and call sites migrated: scoped project settings and the hub's dock/user settings persist under project; the committable workspace class exists for team-shared plugin state (first use: data-inspector saved queries in #101).

Docs

  • New guide page: Cross-Plugin Services (provide/consume, typing via augmentation, ordering, services vs RPC vs shared state), registered in the sidebar
  • Storage-scope reference table on the definition page; the hub guide's host example implements all three scopes
  • DF0037 error page

Verification

683/683 tests (new unit suite for the services host; scope-settings test updated for the storage migration), API snapshots updated (additive), lint/typecheck/build green.


Created with the help of an agent.

Two context-level primitives for plugin interop:

- ctx.services — a typed, namespaced cross-plugin service registry
  (provide/get/whenAvailable, augmentable DevframeServicesRegistry,
  DF0037 on duplicate providers). Providers ship a types-only
  augmentation so consumers get full typing without a runtime
  dependency, and whenAvailable absorbs setup-order differences.

- getStorageDir scopes become workspace/project/global: 'workspace' is
  the committable <workspaceRoot>/.devframe/ dir (team-shared, new),
  'project' is the per-checkout node_modules dir (the previous
  'workspace' semantics), 'global' stays per-user. All hosts and call
  sites migrated: scoped project settings and the hub's dock/user
  settings persist under 'project'.

Docs: a Cross-Plugin Services guide page, storage-scope reference on
the definition page, the hub host example implements all three scopes,
and a DF0037 error page. API snapshots updated.
@netlify

netlify Bot commented Jul 17, 2026

Copy link
Copy Markdown

Deploy Preview for devfra ready!

Name Link
🔨 Latest commit b49fe61
🔍 Latest deploy log https://app.netlify.com/projects/devfra/deploys/6a59a792b7c9420008fca88f
😎 Deploy Preview https://deploy-preview-107--devfra.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@antfu
antfu merged commit 248f3aa into main Jul 17, 2026
11 of 12 checks passed
@antfu
antfu deleted the feat/core-services-storage branch July 17, 2026 03:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants